{% extends 'admin/index.html' %}


{% block con-title %}
    <div class="container-fluid am-cf">
        <div class="row">
            <div class="am-u-sm-12 am-u-md-12 am-u-lg-9">
                <div class="page-header-heading">
                    <span class="am-icon-users page-header-heading-icon"></span>
                     订单管理
                   </div>
            </div>
          
        </div>
    </div>
{% endblock %}

{% block con-body %}

<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title  am-cf">订单列表</div>
                </div>
                <div class="widget-body  am-fr">
                    <div class="am-u-sm-12">
                        <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black ">
                            <thead>
                                <tr>
                                    <th>用户ID</th>

                                    <th>手机号</th>

                                    <th>收货地址</th>

                                    <th>商品名称</th>
                
                                    <th>商品价格</th>
                                    
                                    <th>商品状态</th>

                                    <th>下单时间</th>
                                   
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>

                                {% for v in orders %}
                                <tbody>
                                    {% for vv in v.orderinfo_set.all %}
                                    <tr class="gradeX" style="background-color: #4b5357">

                                        <td class="am-text-middle" style="background-color: #4b5357">
                                            {{ v.uid.id }}
                                        </td>
                                        
                                        <td class="am-text-middle" style="background-color: #4b5357">
                                            {{ v.uid.phone}}
                                        </td>
                                        
                                        <td class="am-text-middle" style="background-color: #4b5357">
                                            {{ v.addressid.address }}
                                        </td>

                                        <td class="am-text-middle" style="background-color: #4b5357">
                                            {{ vv.goodsid.title }}
                                        </td>
                                        
                                        <td class="am-text-middle" style="background-color: #4b5357">
                                            ￥{{ vv.price }} × {{ vv.num }}
                                        </td>
                                        
                                        <td class="am-text-middle" style="background-color: #4b5357">
                                            {% if v.status == 0 %}
                                                    已取消
                                            {% elif v.status == 1 %}
                                                    未支付
                                            {% elif v.status == 2 %}
                                                已付款,待发货
                                            {% endif %}

                                        </td>
                                        
                                    
                                    {% endfor %}
                                        <td class="am-text-middle" style="background-color: #4b5357">{{ v.addtime|date:'Y-m-d H:i:s' }}</td>
                                            <td class="am-text-middle" style="background-color: #4b5357">
                                                <div class="tpl-table-black-operation">
                                                    <a href="/">
                                                        <i class="am-icon-pencil"></i> 发货
                                                    </a>
                                                </div>
                                            </td>
                                        </tr>
                                </tbody>
                                {% endfor %}
                         
                                <!-- more data -->
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">

                        <div class="am-fr">
                            <ul class="am-pagination tpl-pagination">

                            {% load pagetag %}




                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div> 
<script type="text/javascript">
 

     // 给删除的按钮 绑定单击事件
    $('.tpl-table-black-operation-del').click(function(){
        // 获取id
        var id = $(this).attr('sid')
        var btn = $(this)

        // 发送ajax请求,执行数据的删除
        $.get('{% url "myadmin_goods_delete" %}',{id:id},function(data){
            if(data['code']){
                // 在页面中 移除当前这条数据
                btn.parents('tr').find('.isDelete').text('已下架')
            }
            alert(data['msg'])
        },'json')
    })


</script>


{% endblock %}
